{% extends 'homepage.html' %}

{% block content %}
    <!--<div id="header">
        <div class="logo">
            <a href="/Character/Dirichlet">{{ title }} home</a>
        </div>
        <div class="banner">
            <span>The logo of the portal could go here... </span>
        </div>
    </div>-->

<script>
var cur_system = null;
function show_code(system) {
    $('.sage').hide();
    $('.pari').hide();
    $('.magma').hide();
    if (cur_system == null) {
      $('.'+system).show();
      cur_system = system;
    } else {
      $('.'+system).hide();
      cur_system = null;
    }
}
</script>

<style>
.output {
    margin:20px 0;
    text-align: center;
}
table.navi td {
    padding: 0;
}
</style>
        <div align="right">
            <font size="3">Show commands for:</font>
            <a onclick="show_code('sage'); return false" href='#'>sage</a>
        </div>
 
        <!--<h2>
            Sage Output
        </h2>-->
        <div class='sage nodisplay code'>sage: chi = DirichletGroup({{modulus}})[{{number}}]</div>
        <!--<p>
            {{ sagechar }}
            </p>-->

        {% if order == 2 %}
        <h2>
            {{ KNOWL('character.dirichlet.kronecker_symbol') }} Representation
        </h2>
        <div class = 'sage nodisplay code'>sage: a.kronecker({{conductor}})</div>
        <p>
            {{ kronsymbol }}
        </p>
        {% endif %}


        {% if not primitive %}
        <h2>
            Inducing {{ KNOWL('character.dirichlet.induced_character', title="Primitive") }}           </h2>
        <div class = 'sage nodisplay code'>sage: chi.primitive_character()</div>
        <p>
        &nbsp;&nbsp;&nbsp;&nbsp;<a href="{{ url_for('render_webpage_label', modulus=inducedchar_modulus, number=inducedchar_number)}}">{{inducedchar_tex}}</a>
        </p>
        {% endif %}

        <h2>
            {{ KNOWL('character.dirichlet.values', title="Values") }}
        </h2>
        <div class = 'sage nodisplay code'>sage: chi.values()</div>
        {% if root_unity %} &nbsp;&nbsp;&nbsp;For \(\zeta_{ {{ zetaorder }} }\) a primitive \( {{ zetaorder }} \)-th root of unity<br><br/> {% endif %}
        <table>
        <tr>
            <td>   
                <div align="left"> 
                    [\({{ valstex|join("\) , \(") }}\)]
                </div>
            </td>
        </tr>
        </table>
        <h2>
            {{ KNOWL('character.dirichlet.values_on_gens', title="Values on Generators") }}
        </h2>
        <div class = 'sage nodisplay code'>sage: chi.values_on_gens()</div>
        <p>
           &nbsp;&nbsp;&nbsp;&nbsp;\( {{ unitgens }} \) &rarr; \( {{ genvalstex }} \)
        </p>

        <h2> Basic Properties </h2>
        <table>

        <tr>
        <td colspan="4">
            <span class='sage nodisplay code'>sage: chi.conductor()</span>
        </td>
        </tr>
        <tr>
        <td colspan="4">{{ KNOWL('character.dirichlet.conductor', title="Conductor") }}</td>
        <td>=</td>
        <td>\({{ conductor }}\)</td>
        </tr>

        <tr>
        <td colspan="4">
            <span class='sage nodisplay code'>sage: chi.order()</span>
        </td>
        </tr>
        <tr>
        <td colspan="4"> {{ KNOWL('character.dirichlet.order', title="Order") }}</td>
        <td>=</td>
        <td>\({{ order }} \)</td>
        </tr>

        <tr>
        <td colspan="4">
            <span class='sage nodisplay code'>sage: chi.is_even() or chi.is_odd()</span>
        </td>
        </tr>
        <tr>
        <td colspan="4"> {{ KNOWL('character.dirichlet.parity', title="Parity") }} </td>
        <td>=</td>
        <td> {{ parity }}</td>
        </tr>

        <tr>
        {% if sign=="False" %} <td colspan="4"> {{ KNOWL('character.dirichlet.complex', title="Complex") }} </td>
        {% else %} <td colspan="4"> {{ KNOWL('character.dirichlet.real', title="Real") }} </td>
        {% endif %}
        </tr>

        <tr>
            <td colspan="4">
                <span class='sage nodisplay code'>sage: chi.is_primitive()</span>
            </td>
        </tr>
        <tr>
        {% if primitive=="False" %} <td colspan="4"> {{ KNOWL('character.dirichlet.primitive', title="Non-primitive") }} </td> 
        {% else %} <td colspan="4"> {{ KNOWL('character.dirichlet.primitive', title="Primitive") }} </td>
        {% endif %}
        </tr>

       </table>

        <h2>
            {{ KNOWL('character.dirichlet.gauss_sum') }}
        </h2>
        <div class = 'sage nodisplay code'>sage: chi.gauss_sum()</div>
        <form> &nbsp;&nbsp;&nbsp;{{ gauss_sum }} 
            <input id="calc-gauss-input" size=10 placeholder="2">
            <button id="calc-gauss-go">Go</button>
            <span class="formexample"> e.g. 2 </span>
        </form>
        <div class="output"><span id="calc-gauss-output"></span></div>
        <h2>
            {{ KNOWL('character.dirichlet.jacobi_sum') }}
        </h2>
        <div class = 'sage nodisplay code'>sage: chi.jacobi_sum()</div>
        <form> &nbsp;&nbsp;&nbsp;{{ jacobi_sum }} 
            <input id="calc-jacobi-input" size="10" placeholder="13.2">
            <button id="calc-jacobi-go"> Go </button>
            <span class="formexample"> e.g. 13.2 </span>
        </form>
        <div class="output"><span id="calc-jacobi-output"></span></div>
        <h2>
            {{ KNOWL('character.dirichlet.kloosterman_sum') }}
        </h2>
        <div class = 'sage nodisplay code'>sage: chi.kloosterman_sum(,)</div>
        <form> &nbsp;&nbsp;&nbsp;{{ kloosterman_sum }} 
            <input id="calc-kloosterman-input" size=10 placeholder="1,2">
            <button id="calc-kloosterman-go"> Go </button>
            <span class="formexample"> e.g. 1,2</span>
        </form>
        <div class="output"><span id="calc-kloosterman-output"></span></div>

<script type="text/javascript">
function gauss_handler(evt) {
   evt.preventDefault();
   var val = $("#calc-gauss-input").val();
   $("#calc-gauss-output").load("{{ url_for('dc_calc_gauss', modulus=modulus,number=number) }}" + "?val=" + val, 
     function() {
       {# tell mathjx to render the output #}
       MathJax.Hub.Queue(['Typeset', MathJax.Hub, "calc-gauss-output"]);
     });
}

function jacobi_handler(evt) {
   evt.preventDefault();
   var val = $("#calc-jacobi-input").val();
   $("#calc-jacobi-output").load("{{ url_for('dc_calc_jacobi', modulus=modulus,number=number) }}" + "?val=" + val,
     function() {
       {# tell mathjx to render the output #}
       MathJax.Hub.Queue(['Typeset', MathJax.Hub, "calc-jacobi-output"]);
     });
}

function kloosterman_handler(evt) {
   evt.preventDefault();
   var val = $("#calc-kloosterman-input").val();
   $("#calc-kloosterman-output").load("{{ url_for('dc_calc_kloosterman', modulus=modulus,number=number) }}" + "?val=" + val,
     function() {
       {# tell mathjx to render the output #}
       MathJax.Hub.Queue(['Typeset', MathJax.Hub, "calc-kloosterman-output"]);
     });
}

$(function() {
    $("#calc-gauss-go").click(function(e) {gauss_handler(e)});
    $("#calc-jacobi-go").click(function(e) {jacobi_handler(e)});
    $("#calc-kloosterman-go").click(function(e) {gauss_handler(e)});
    $("#calc-gauss-input").keypress(function(e) {
      if (e.which == 13) gauss_handler(e);
    });
    $("#calc-jacobi-input").keypress(function(e) {
        if (e.which == 13) jacobi_handler(e);
    });
    $("#calc-kloosterman-input").keypress(function(e) {
        if (e.which == 13) kloosterman_handler(e);
    });
});

</script>
{% endblock %}

